package com.example.walletspringbootproject.rest.UserWallet.impl;

import com.example.walletspringbootproject.cell.UserWallet.service.SelectUserRecordService;
import com.example.walletspringbootproject.model.UserWallet.DTO.UserRecordDto;
import com.example.walletspringbootproject.model.UserWallet.Entity.UserWalletEntity;
import com.example.walletspringbootproject.rest.UserWallet.api.queryUserWallet;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/v1")
public class queryUserWalletImpl implements queryUserWallet {

    @Resource
    SelectUserRecordService userWalletServices;

    /**
     * 查询用户流水，只支持userUuid查询 or actionType操作类型筛选
     * 操作类型：固定值 1：充值，2:消费，3：退款,
     *
     * @param userRecordDto
     * @return List<UserRecordDto>
     */
    @RequestMapping(value = "/queryUserRecord", method = RequestMethod.POST)
    @Override
    public List<UserRecordDto> queryUserRecord(@RequestBody UserRecordDto userRecordDto) {
      return userWalletServices.selectUserRecordList(userRecordDto);
    }

    /**
     * 查询用户钱包，充值总金额，可用余额，总支出等等，只支持userUuid查询
     *
     * @param userRecordDto
     * @return
     */
    @RequestMapping(value = "/queryUserWallet", method = RequestMethod.POST)
    @Override
    public UserWalletEntity queryUserWallet(@RequestBody UserRecordDto userRecordDto) {
        return userWalletServices.selectByPrimaryKey(userRecordDto);
    }
}
